﻿#region Using Statements
using GameBase.Cameras;
using Microsoft.Xna.Framework;
#endregion

namespace StarFox.Graphics
{
    /// <summary>
    /// Provides a basic implementation of a camera.
    /// </summary>
    public class Camera : ICamera
    {
        #region Properties

        // backing fields
        Matrix view;
        Matrix projection;
        Vector3 position;
        Vector3 right;
        Vector3 up;
        Vector3 forward;

        /// <summary>
        /// Gets or sets the camera's view matrix.
        /// </summary>
        public Matrix View
        {
            get { return view; }
            set
            {
                view = value;
                position = Matrix.Invert(view).Translation;
                right = Matrix.Invert(view).Right;
                up = Matrix.Invert(view).Up;
                forward = Matrix.Invert(view).Forward;
            }
        }

        /// <summary>
        /// Gets or sets the camera's projection matrix.
        /// </summary>
        public Matrix Projection 
        {
            get { return projection; }
            set { projection = value; }
        }

        /// <summary>
        /// Gets the camera's position.
        /// </summary>
        public Vector3 Position
        {
            get { return position; }
        }

        /// <summary>
        /// Gets the direction that is "right" from the camera's point of view.
        /// </summary>
        public Vector3 Right 
        {
            get { return right; }
        
        }

        /// <summary>
        /// Gets the direction that is "up" from the camera's point of view.
        /// </summary>
        public Vector3 Up 
        {
            get { return up; }
        }

        /// <summary>
        /// Gets the direction that is "forward" from the camera's point of view.
        /// </summary>
        public Vector3 Forward 
        {
            get { return forward; }
        }

        #endregion
    }
}
